home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume14 / xxgdb / patch3 next >
Encoding:
Internet Message Format  |  1991-10-25  |  51.9 KB

  1. Path: uunet!sun-barr!cronkite.Central.Sun.COM!exodus!la.tce.com
  2. From: pierre@la.tce.com (Pierre Willard)
  3. Newsgroups: comp.sources.x
  4. Subject: v14i100: xxgdb, Patch3, Part01/01
  5. Message-ID: <22139@exodus.Eng.Sun.COM>
  6. Date: 25 Oct 91 16:31:44 GMT
  7. References: <csx-14i100-xxgdb@uunet.UU.NET>
  8. Sender: news@exodus.Eng.Sun.COM
  9. Lines: 1867
  10. Approved: argv@sun.com
  11.  
  12. Submitted-by: pierre@la.tce.com (Pierre Willard)
  13. Posting-number: Volume 14, Issue 100
  14. Archive-name: xxgdb/patch3
  15. Patch-To: xxgdb: Volume 11, Issue 42-55
  16. Patch-To: xxgdb: Volume 12, Issue 78
  17. Patch-To: xxgdb: Volume 13, Issue 80
  18.  
  19.  
  20.     XXGDB version 1.05 ( X window interface to the GDB debugger )
  21.     -------------------------------------------------------------
  22.  
  23. Posting history :
  24. January 91 : xxgdb 1.01 complete source files (Volume 11, Issue 42-55),
  25. May 91 :     xxgdb 1.03 (patch from 1.01) (Volume 12, Issue 78),
  26. July 91 :    xxgdb 1.04 (patch from 1.03) (Volume 13, Issue 80).
  27.  
  28. Please find in the following the differences from version
  29. 1.04 to 1.05.
  30.  
  31. Please post this complete message to comp.sources.x
  32.  
  33. NEW FEATURES OF VERSION 1.05  :
  34.  
  35.     RUNS WITH GDB-4.0 (and versions 3.xx too),
  36.     Fix tiny bug in search function.
  37.  
  38.  
  39. I did not test xxgdb with the new gdb-4.1, I hope it works.
  40. I would welcome any comments and bug reports.
  41.  
  42. I would also appreciate if anyone out there using xxgdb
  43. could drop me a mail (at pierre@la.tce.com) so I know
  44. how many you are.
  45.  
  46. Also, if you know a site where is kept the complete source
  47. of xxgdb, I would like you to tell me because this is a
  48. question I am often asked.
  49.  
  50. TO PATCH XXGDB FROM VERSION 1.04 TO VERSION 1.05 :
  51.  
  52.     cd <original xxgdb 1.04 source directory>
  53.     chmod +rw *
  54.     patch < <patch_file>
  55.     
  56. THE FOLLOWING IS THE PATCH FILE FOR XXGDB 1.05 FROM XXGDB 1.04 :
  57. diff -rc2 v1.04/Makefile v1.05/Makefile
  58. *** v1.04/Makefile    Thu May 30 15:39:41 1991
  59. --- v1.05/Makefile    Wed Aug 28 18:35:53 1991
  60. ***************
  61. *** 42,46 ****
  62.                  AR = ar cq
  63.     BOOTSTRAPCFLAGS =
  64. !                CC = cc
  65.   
  66.            COMPRESS = compress
  67. --- 42,46 ----
  68.                  AR = ar cq
  69.     BOOTSTRAPCFLAGS =
  70. !                CC = gcc -v
  71.   
  72.            COMPRESS = compress
  73. diff -rc2 v1.04/XXGDB_README v1.05/XXGDB_README
  74. *** v1.04/XXGDB_README    Tue Jul  9 13:36:08 1991
  75. --- v1.05/XXGDB_README    Mon Sep 23 16:13:14 1991
  76. ***************
  77. *** 108,112 ****
  78.       Thomson Consumer Electronics, Inc.
  79.   
  80. ! XXGDB version 1.03
  81.   ------------------
  82.   
  83. --- 108,112 ----
  84.       Thomson Consumer Electronics, Inc.
  85.   
  86. ! XXGDB version 1.05
  87.   ------------------
  88.   
  89. ***************
  90. *** 117,120 ****
  91. --- 117,122 ----
  92.       GDB must be accessible in the current path.
  93.       
  94. +     xxgdb should run the new gdb 4.0 (as well as the older versions).
  95. +     
  96.       This X window interface has been adapted to GDB from the source
  97.       distribution files of XDBX version 2.1 (patch level 2) which
  98. ***************
  99. *** 138,149 ****
  100.       the R4 release of X11 for both.
  101.               
  102. !     - XXGDB changes the GDB default 'set prettyprint' to ON. This is
  103. !     necessary to be able to display the pointed object when clicking
  104. !     a pointer value in a popup window (see also 'Displaying C Data
  105. !     Structures' in xdbx documentation). Except for this feature,
  106. !     xxgdb works with 'set prettyprint off'.
  107.       
  108. !     - XXGDB changes the GDB default 'set screensize' to 0.
  109.   
  110.       - With the 'list' command, XXGDB will put the cursor at the last 
  111.       listed line and will make sure that this last line is visible
  112. --- 140,155 ----
  113.       the R4 release of X11 for both.
  114.               
  115. !     - XXGDB changes the GDB default 'set prettyprint' to ON (or 'set
  116. !     p pretty' if gdb 4.0). This is necessary to be able to display
  117. !     the pointed object when clicking a pointer value in a popup window
  118. !     (see also 'Displaying C Data Structures' in xdbx documentation).
  119. !     Except for this feature, xxgdb works with 'set prettyprint off'.
  120.       
  121. !     - XXGDB changes the GDB default 'set screensize' to 0 (or 
  122. !     'set height' and 'set width' to 0 if gdb 4.0).
  123.   
  124. +     - XXGDB changes the GDB default 'set confirm' to off (if gdb 4.0).
  125. +     THIS IS IMPORTANT. DO NOT SET CONFIRM TO OFF OR XXGDB MIGHT HANG. 
  126.       - With the 'list' command, XXGDB will put the cursor at the last 
  127.       listed line and will make sure that this last line is visible
  128. ***************
  129. *** 200,203 ****
  130. --- 206,211 ----
  131.           because xxgdb does not interpret what the defined commands
  132.           do.
  133. +         
  134. +     - 'set confirm off' might hang xxgdb later on.
  135.       
  136.       - 'source' command of XXGDB behaves slighlty differently from 
  137. ***************
  138. *** 204,208 ****
  139.       the one in GDB. The specified file is read line by line by xxgdb
  140.       and each line is sent to gdb. Thus gdb will ask confirmation of
  141. !     some commands. 
  142.       This is also the case for the execution of the '.gdbinit' file.
  143.       
  144. --- 212,217 ----
  145.       the one in GDB. The specified file is read line by line by xxgdb
  146.       and each line is sent to gdb. Thus gdb will ask confirmation of
  147. !     some commands (except for gdb 4.0 because of 'set confirm off'
  148. !     used by xxgdb).
  149.       This is also the case for the execution of the '.gdbinit' file.
  150.       
  151. ***************
  152. *** 209,219 ****
  153.       - Repeat command of XXGDB behaves slighlty differently from the one
  154.       in GDB.
  155. -     
  156. -     - Clicking too rapidly on the buttons will sometimes hang gdb.
  157. -     It is WISE to wait for the completion of the previous command
  158. -     before sending any new command to gdb. Note that sending the
  159. -     SIGCONT (19) signal to gdb seems to fix this problem.
  160. -     
  161.   
  162.   XXGDB history
  163.   -------------
  164. --- 218,224 ----
  165.       - Repeat command of XXGDB behaves slighlty differently from the one
  166.       in GDB.
  167.   
  168.   XXGDB history
  169.   -------------
  170. ***************
  171. *** 247,250 ****
  172. --- 252,258 ----
  173.                   fix problem scrolling symbols while scrolling with keys (GWC).
  174.                   fix bug displaying arrow when up/down in recursive function.
  175. +     1.05    July - September 1991
  176. +                 Fix bug in search window.
  177. +                 Update for gdb 4.0 (PW)(SH).
  178.                   
  179.   
  180. ***************
  181. *** 254,261 ****
  182.       Thanks to Guy Cherry (GWC) for his numerous bug reports and
  183.       suggestions, and to all of you who helped improve xxgdb.
  184. -     
  185.       Thanks to j braham levy (JBL) for his modifications for
  186.       generic BSD machines.
  187. !     
  188.       
  189.                   --------------------------
  190. --- 262,269 ----
  191.       Thanks to Guy Cherry (GWC) for his numerous bug reports and
  192.       suggestions, and to all of you who helped improve xxgdb.
  193.       Thanks to j braham levy (JBL) for his modifications for
  194.       generic BSD machines.
  195. !     Thanks to Stephan Heuer (SH) for some updates to gdb 4.0.
  196.       
  197.                   --------------------------
  198. diff -rc2 v1.04/command.c v1.05/command.c
  199. *** v1.04/command.c    Fri Apr 12 17:04:49 1991
  200. --- v1.05/command.c    Mon Sep 23 13:59:50 1991
  201. ***************
  202. *** 456,482 ****
  203.       searchlength = strlen(searchstring);
  204.       searchsize = strlen(text) - searchlength;
  205. !     for (i=startpos; i < searchsize; i++) {
  206.       n = searchlength;
  207.       s1 = &text[i];
  208.       s2 = searchstring;
  209. !     while (--n >= 0 && *++s1 == *s2++);
  210.       if (n < 0) break;
  211.       }
  212.       if (n < 0) {
  213. !         *left = i+1;
  214. !         *right = i+1+searchlength;
  215.           return 1;
  216.       }
  217.       else {
  218. !     for (i=0; i < startpos; i++) {
  219.           n = searchlength;
  220.           s1 = &text[i];
  221.           s2 = searchstring;
  222. !         while (--n >= 0 && *++s1 == *s2++);
  223.           if (n < 0) break;
  224.       }
  225.       if (n < 0) {
  226. !         *left = i+1;
  227. !         *right = i+1+searchlength;
  228.           return 1;
  229.       }
  230. --- 456,482 ----
  231.       searchlength = strlen(searchstring);
  232.       searchsize = strlen(text) - searchlength;
  233. !     for (i=startpos+1; i < searchsize; i++) {
  234.       n = searchlength;
  235.       s1 = &text[i];
  236.       s2 = searchstring;
  237. !     while (--n >= 0 && *s1++ == *s2++);
  238.       if (n < 0) break;
  239.       }
  240.       if (n < 0) {
  241. !         *left = i;
  242. !         *right = i+searchlength;
  243.           return 1;
  244.       }
  245.       else {
  246. !     for (i=0; i <= startpos; i++) {
  247.           n = searchlength;
  248.           s1 = &text[i];
  249.           s2 = searchstring;
  250. !         while (--n >= 0 && *s1++ == *s2++);
  251.           if (n < 0) break;
  252.       }
  253.       if (n < 0) {
  254. !         *left = i;
  255. !         *right = i+searchlength;
  256.           return 1;
  257.       }
  258. ***************
  259. *** 498,502 ****
  260.   
  261.       searchlength = strlen(searchstring);
  262. !     for (i=startpos; i > searchlength; i--) {
  263.       n = searchlength;
  264.       s1 = &text[i];
  265. --- 498,502 ----
  266.   
  267.       searchlength = strlen(searchstring);
  268. !     for (i=startpos; i >= searchlength; i--) {
  269.       n = searchlength;
  270.       s1 = &text[i];
  271. ***************
  272. *** 511,515 ****
  273.       }
  274.       else {
  275. !     for (i=strlen(text)-1; i > startpos; i--) {
  276.           n = searchlength;
  277.           s1 = &text[i];
  278. --- 511,515 ----
  279.       }
  280.       else {
  281. !     for (i=strlen(text); i > startpos; i--) {
  282.           n = searchlength;
  283.           s1 = &text[i];
  284. ***************
  285. *** 817,823 ****
  286.       q->next = p;
  287.       }
  288. !     write_dbx(command);
  289. !     
  290. !     Prompt = FALSE;        /* (PW)12APR91 : no more Prompt now. */
  291.   }
  292.   
  293. --- 817,822 ----
  294.       q->next = p;
  295.       }
  296. !     write_dbx_available();
  297.   }
  298.   
  299. diff -rc2 v1.04/datadpy.c v1.05/datadpy.c
  300. *** v1.04/datadpy.c    Mon Apr 15 09:19:39 1991
  301. --- v1.05/datadpy.c    Fri Sep 20 14:34:56 1991
  302. ***************
  303. *** 246,250 ****
  304. --- 246,254 ----
  305.       sprintf(command, "print *(%s)\n", name);
  306.       PopupMode = True;
  307. + #ifdef GDB
  308. +     query_gdb(command, PARSE_ON | ECHO_OFF | FILTER_OFF);
  309. + #else
  310.       query_dbx(command);
  311. + #endif
  312.       }
  313.   }
  314. diff -rc2 v1.04/dbx.c v1.05/dbx.c
  315. *** v1.04/dbx.c    Tue May  7 14:59:14 1991
  316. --- v1.05/dbx.c    Fri Sep 20 16:04:33 1991
  317. ***************
  318. *** 135,138 ****
  319. --- 135,139 ----
  320.   }
  321.   
  322. + #ifndef GDB
  323.   /*
  324.    *  This is a callback procedure invoked everytime when input is pending
  325. ***************
  326. *** 183,192 ****
  327.       command = get_command();
  328.           
  329. - #ifdef GDB
  330. -     if (Echo || Filter)
  331. -         filter(string, output, command);
  332. -     if (Echo && Prompt)
  333. -         AppendDialogText(xdbxprompt);
  334. - #else
  335.       if (Echo) {
  336.           filter(string, output, command);
  337. --- 184,187 ----
  338. ***************
  339. *** 193,197 ****
  340.           if (Prompt) AppendDialogText(xdbxprompt);
  341.       }
  342. - #endif
  343.       if (string) {
  344.           XtFree(string);
  345. --- 188,191 ----
  346. ***************
  347. *** 211,214 ****
  348. --- 205,209 ----
  349.       }
  350.   }
  351. + #endif /* not GDB */
  352.   
  353.   /*  Write string s to dbx, and flush the output.  */
  354. ***************
  355. *** 224,238 ****
  356.   }
  357.   
  358. ! #ifdef GDB
  359. ! /*  Sends a command to dbx and read the corresponding output, directly
  360. !  *  invoking the Xt input procedure, read_dbx().
  361. !  */
  362. ! void query_dbx(command)
  363. ! char *command;
  364. ! {
  365. !     query_dbx_echo(command, False, False);
  366. ! }
  367. ! #else
  368.   /*  Sends a command to dbx and read the corresponding output, directly
  369.    *  invoking the Xt input procedure, read_dbx().
  370. --- 219,223 ----
  371.   }
  372.   
  373. ! #ifndef GDB
  374.   /*  Sends a command to dbx and read the corresponding output, directly
  375.    *  invoking the Xt input procedure, read_dbx().
  376. diff -rc2 v1.04/defs.h v1.05/defs.h
  377. *** v1.04/defs.h    Fri Apr 12 10:06:28 1991
  378. --- v1.05/defs.h    Fri Sep 20 16:04:42 1991
  379. ***************
  380. *** 256,257 ****
  381. --- 256,268 ----
  382.       char     func[MAXNAME];        /* function name associated with */
  383.   } Bomb;
  384. + #ifdef GDB
  385. + /* defined flags for query_gdb_gen() and read_gdb() */
  386. + #define PARSE_ON    1
  387. + #define PARSE_OFF    0
  388. + #define ECHO_ON        2
  389. + #define ECHO_OFF    0
  390. + #define FILTER_ON    4
  391. + #define FILTER_OFF    0
  392. + #endif
  393. diff -rc2 v1.04/dialog.c v1.05/dialog.c
  394. *** v1.04/dialog.c    Mon Mar 11 15:59:05 1991
  395. --- v1.05/dialog.c    Mon Sep 23 14:36:07 1991
  396. ***************
  397. *** 196,200 ****
  398.       static char gdb_command[LINESIZ] = " \n";
  399.   #endif
  400. !     char s[LINESIZ];
  401.   
  402.       strcpy(s, DialogText + StartPos);
  403. --- 196,200 ----
  404.       static char gdb_command[LINESIZ] = " \n";
  405.   #endif
  406. ! char s[LINESIZ];
  407.   
  408.       strcpy(s, DialogText + StartPos);
  409. ***************
  410. *** 205,227 ****
  411.   #endif
  412.   
  413. !     if (Prompt) {
  414. ! #ifdef GDB
  415. !     if (gdb_source_command(s,FALSE))    /* filter source command (& do not display source command) */
  416. !         {
  417. !         strcpy(gdb_command," \n");    /* do not execute anything if next command is '\n' */
  418. !         return;
  419.           }
  420. !     /* When we send \n to gdb, it executes the last command,
  421. !     so better tell xxgdb what gdb is doing */
  422. !     if (strcmp(s, "\n"))
  423. !         strcpy(gdb_command,s);
  424. !     else
  425. !         strcpy(s,gdb_command);
  426. ! #endif /* GDB */
  427. !     send_command(s);
  428. !     }
  429. !     else {
  430.           write_dbx(s);
  431. -     }
  432.   }
  433.   
  434. --- 205,226 ----
  435.   #endif
  436.   
  437. !     if (Prompt)
  438. !         {
  439. !         /* When we send \n to gdb, it executes the last command,
  440. !         so better tell xxgdb what gdb is doing */
  441. !         if (strcmp(s, "\n"))
  442. !             strcpy(gdb_command,s);    /* if not "\n" ! */
  443. !         else
  444. !             {
  445. !             /* copy previous command in new command, and
  446. !             echo the command in the dialog window. */
  447. !             strcpy(s,gdb_command);
  448. !             AppendDialogText(gdb_command);
  449. !             }
  450. !         send_command (s);
  451.           }
  452. !     else
  453. !         /* this string is for the application, not for gdb */
  454.           write_dbx(s);
  455.   }
  456.   
  457. diff -rc2 v1.04/filemenu.c v1.05/filemenu.c
  458. *** v1.04/filemenu.c    Wed Apr  3 14:12:30 1991
  459. --- v1.05/filemenu.c    Mon Sep 23 13:51:58 1991
  460. ***************
  461. *** 136,140 ****
  462.       LASTCH(cwd) = '\0';
  463.       }
  464. ! #else
  465.       if(!strcmp(dir,"../"))
  466.          {
  467. --- 136,140 ----
  468.       LASTCH(cwd) = '\0';
  469.       }
  470. ! #else    /* not BSD */
  471.       if(!strcmp(dir,"../"))
  472.          {
  473. ***************
  474. *** 151,156 ****
  475.         }
  476.       sprintf(command, "cd %s\n", store);
  477.       query_dbx(command);
  478. ! #endif
  479.   }
  480.   
  481. --- 151,160 ----
  482.         }
  483.       sprintf(command, "cd %s\n", store);
  484. + #ifdef GDB
  485. +     query_gdb(command, PARSE_ON | ECHO_OFF | FILTER_OFF);
  486. + #else
  487.       query_dbx(command);
  488. ! #endif    /* not GDB */
  489. ! #endif    /* BSD */
  490.   }
  491.   
  492. ***************
  493. *** 318,347 ****
  494.           UpdateMessageWindow("",NULL);
  495.   #ifdef GDB
  496. -     /* for GDB, we send the commands : exec-file & symbol-file */
  497. -     
  498. -     /* (PW)21DEC90 : this button is special because it has to send
  499. -     TWO commands to GDB. We should wait for the prompt before
  500. -     sending the second command !. 
  501. -     I think it is cleaner to send this 2nd command in the parser
  502. -     after it matches 'exec-file' command.
  503. -     But do that latter
  504. -     */
  505. -     
  506.       strcpy(string, filename);
  507.       LASTCH(string) = '\0';
  508. -     
  509. -     sprintf(command, "exec-file %s\n", string);
  510. -     send_command(command);
  511. -         AppendDialogText(command);
  512. -         
  513. -     Echo = True;
  514. -     Parse = True;
  515. -     Prompt = False;
  516. -     while (!Prompt)
  517. -         read_dbx();
  518.   
  519. !     sprintf(command, "symbol-file %s\n", string);
  520.       send_command(command);
  521. !         AppendDialogText(command);
  522.   #else
  523.   #ifndef BSD
  524. --- 322,346 ----
  525.           UpdateMessageWindow("",NULL);
  526.   #ifdef GDB
  527.       strcpy(string, filename);
  528.       LASTCH(string) = '\0';
  529.   
  530. !     /* for GDB 4.xx, we send the command : file */
  531. !     if (new_gdb4())
  532. !         sprintf(command, "file %s\n", string);
  533. !     else
  534. !         {
  535. !         /* for GDB 3.xx, we send the commands : exec-file & symbol-file */
  536. !         
  537. !         /* (PW)21DEC90 : this button is special because it has to send
  538. !         TWO commands to GDB. */
  539. !         
  540. !         sprintf(command, "exec-file %s\n", string);
  541. !         send_command(command);
  542. !             AppendDialogText(command);
  543. !             
  544. !         sprintf(command, "symbol-file %s\n", string);
  545. !         }
  546.       send_command(command);
  547. !     AppendDialogText(command);
  548.   #else
  549.   #ifndef BSD
  550. ***************
  551. *** 446,450 ****
  552.       SetUpFileMenu(cwd);
  553.   #ifdef GDB
  554. !     query_dbx("info directories\n");
  555.   #else
  556.       query_dbx("use\n");
  557. --- 445,449 ----
  558.       SetUpFileMenu(cwd);
  559.   #ifdef GDB
  560. !     query_gdb_directories();  /* defined in gdb_handler.c */
  561.   #else
  562.       query_dbx("use\n");
  563. diff -rc2 v1.04/gdb_handler.c v1.05/gdb_handler.c
  564. *** v1.04/gdb_handler.c    Tue May  7 14:59:11 1991
  565. --- v1.05/gdb_handler.c    Mon Sep 23 16:00:42 1991
  566. ***************
  567. *** 83,87 ****
  568.    *    done_handler():        Progrm execution completed, clear breakpoints
  569.    *    source_handler():        Exec commands of source file specified.
  570. !  *    query_dbx_echo():        Send command with echo on or off, filter on/off.
  571.    */
  572.   
  573. --- 83,87 ----
  574.    *    done_handler():        Progrm execution completed, clear breakpoints
  575.    *    source_handler():        Exec commands of source file specified.
  576. !  *    query_gdb():            Send command to gdb.
  577.    */
  578.   
  579. ***************
  580. *** 90,94 ****
  581.   #endif
  582.   
  583. - void query_dbx_echo();
  584.   
  585.   /*  
  586. --- 90,93 ----
  587. ***************
  588. *** 129,146 ****
  589.   void debug_handler()
  590.   {
  591. !     /* debug_handler is executed at start-up and with 'symbol-file' command */
  592.       
  593. !     query_dbx("set screensize 0\n");
  594. !     query_dbx("set prettyprint on\n");
  595. !     query_dbx("info directories\n");
  596.       
  597.       displayedFile = NULL;        /* force reloading of source file */
  598.    
  599. !      /* here we use query_dbx_echo instead of query_dbx so that any
  600. !      error message will be displayed ! (because Filter is True) */
  601. !      
  602. !      query_dbx_echo("list ,main\n", False, True);    /* tell gdb to use main file 
  603. !                                  and get line number of main(). (,main will end at main) */
  604. !    
  605.       if (LoadCurrentFile() == 0)
  606.           {
  607. --- 128,159 ----
  608.   void debug_handler()
  609.   {
  610. !     /* debug_handler is executed at start-up and with 'symbol-file' command and
  611. !     with 'file' command (gdb 4.0) */
  612.       
  613. !     info_source_handler(NULL);    /* say no current compilation directory */
  614. !     
  615. !     query_gdb_directories();
  616. !     if (new_gdb4()) /* (PW)28AUG91: test for gdb 4.0 */
  617. !         {
  618. !         /* (SH) for gdb 4.0 */
  619. !         query_gdb("set height 0\n",        PARSE_OFF | ECHO_OFF | FILTER_OFF);    
  620. !         query_gdb("set width 0\n",         PARSE_OFF | ECHO_OFF | FILTER_OFF);
  621. !         query_gdb("set p pretty on\n",    PARSE_OFF | ECHO_OFF | FILTER_OFF);
  622. !         query_gdb("set confirm off\n",    PARSE_OFF | ECHO_OFF | FILTER_OFF);
  623. !         }
  624. !     else
  625. !         {
  626. !         query_gdb("set screensize 0\n",        PARSE_OFF | ECHO_OFF | FILTER_OFF);
  627. !         query_gdb("set prettyprint on\n",    PARSE_OFF | ECHO_OFF | FILTER_OFF);
  628. !         }
  629.       
  630.       displayedFile = NULL;        /* force reloading of source file */
  631.    
  632. !      /* here we use FILTER_ON so that any error message will be displayed ! */
  633. !     /* tell gdb to use main file and get line number of main(). (,main will end at main) */
  634. !     
  635. !      query_gdb("list ,main\n", PARSE_ON | ECHO_OFF | FILTER_ON); 
  636.       if (LoadCurrentFile() == 0)
  637.           {
  638. ***************
  639. *** 156,160 ****
  640.           
  641.       UpdateMessageWindow("Ready for execution",NULL);
  642. !     query_dbx("display\n");        /* clear display window */
  643.   }
  644.   
  645. --- 169,176 ----
  646.           
  647.       UpdateMessageWindow("Ready for execution",NULL);
  648. !     
  649. !     /* clear display window */
  650. !     
  651. !     query_gdb("display\n", PARSE_ON | ECHO_OFF | FILTER_OFF);
  652.   }
  653.   
  654. ***************
  655. *** 274,278 ****
  656.       directory only. GDB requires confirmation */
  657.       
  658. !     query_dbx("info directories\n");    
  659.   }
  660.   
  661. --- 290,294 ----
  662.       directory only. GDB requires confirmation */
  663.       
  664. !     query_gdb_directories();
  665.   }
  666.   
  667. ***************
  668. *** 285,288 ****
  669. --- 301,308 ----
  670.       if (line)
  671.           {
  672. +         /* update compilation directory (if gdb 4.0) before loading source file */
  673. +         if (new_gdb4())
  674. +             query_gdb("info source\n", PARSE_ON | ECHO_OFF | FILTER_OFF);
  675. +         
  676.           /* We will display the last line listed. 
  677.           Since we used 'list ,main' we will effectively display main in that case. */
  678. ***************
  679. *** 317,321 ****
  680.   void delete_handler()
  681.   {
  682. !     query_dbx("info break\n");    /* update breakpoints */
  683.   }
  684.   
  685. --- 337,342 ----
  686.   void delete_handler()
  687.   {
  688. !     /* update breakpoints */
  689. !     query_gdb("info break\n", PARSE_ON | ECHO_OFF | FILTER_OFF);
  690.   }
  691.   
  692. ***************
  693. *** 322,326 ****
  694.   void display_handler()    /* display or undisplay */
  695.   {
  696. !     query_dbx_echo("display\n",False, True);    /* update display */
  697.   }
  698.   
  699. --- 343,348 ----
  700.   void display_handler()    /* display or undisplay */
  701.   {
  702. !     /* update display */
  703. !     query_gdb("display\n", PARSE_ON | ECHO_OFF | FILTER_ON);
  704.   }
  705.   
  706. ***************
  707. *** 434,442 ****
  708.       /* because of tbreak, we have to call info break here */
  709.       
  710. !     query_dbx("info break\n");    /* update breakpoints */
  711.   
  712.       if (func == NULL)
  713.           {
  714. !         query_dbx("frame\n"); /* this will just update funcname (see frame_curr_handler) */
  715.           func = funcname;
  716.           if (func == NULL)
  717. --- 456,476 ----
  718.       /* because of tbreak, we have to call info break here */
  719.       
  720. !      query_gdb("info break\n", PARSE_ON | ECHO_OFF | FILTER_OFF); /* update breakpoints */
  721.   
  722.       if (func == NULL)
  723.           {
  724. !         /* because silly gdb 4.0 displays nothing with frame command when
  725. !         confirm is on (possibly a gdb bug) , I just reset confirm to on
  726. !         just for this command !. */
  727. !         
  728. !         if (new_gdb4()) 
  729. !             query_gdb("set confirm on\n",    PARSE_OFF | ECHO_OFF | FILTER_OFF);
  730. !             
  731. !         /* this will just update funcname (see frame_curr_handler()) */
  732. !         query_gdb("frame\n", PARSE_ON | ECHO_OFF | FILTER_OFF);
  733. !         
  734. !         if (new_gdb4()) /* reset confirm to off */
  735. !             query_gdb("set confirm off\n",    PARSE_OFF | ECHO_OFF | FILTER_OFF);
  736. !             
  737.           func = funcname;
  738.           if (func == NULL)
  739. ***************
  740. *** 472,475 ****
  741. --- 506,510 ----
  742.    *  change the file variable to the file name displayed.
  743.    */
  744. + /* ARGSUSED */
  745.   void done_handler(message,signal)
  746.   char *message;
  747. ***************
  748. *** 485,489 ****
  749.   /*--------------------------------------------------------------------------+
  750.   |                                                                            |
  751. ! |    Function to read the .dgbinit file or any source file.                    |
  752.   |                                                                            |
  753.   |    input : file name.                                                        |
  754. --- 520,524 ----
  755.   /*--------------------------------------------------------------------------+
  756.   |                                                                            |
  757. ! |    Function to read the .gdbinit file or any source file.                    |
  758.   |                                                                            |
  759.   |    input : file name.                                                        |
  760. ***************
  761. *** 510,521 ****
  762.               if ((*s != '#') && strcmp(s,"\n"))    
  763.                   {
  764. !                 if (gdb_source_command(s,TRUE) || gdb_define_command(s,fp))
  765. !                     {
  766. !                         Prompt = False;
  767. !                     while (!Prompt)
  768. !                         read_dbx();
  769. !                     }
  770. !                 else
  771. !                     query_dbx_echo (s, TRUE, TRUE);
  772.                   }
  773.               }
  774. --- 545,550 ----
  775.               if ((*s != '#') && strcmp(s,"\n"))    
  776.                   {
  777. !                 if (!(gdb_source_command(s,TRUE) || gdb_define_command(s,fp)))
  778. !                     query_gdb(s, PARSE_ON | ECHO_ON | FILTER_ON);
  779.                   }
  780.               }
  781. ***************
  782. *** 549,578 ****
  783.   }
  784.   
  785. - /*  Sends a command to dbx and read the corresponding output, directly
  786. -  *  invoking the Xt input procedure, read_dbx().
  787. -  *
  788. -  *    Same as query_dbx() in dbx.c except that Echo = True or False.
  789. -  *  and in case Echo = False, filter says if filter() must be called.
  790. -  */
  791. - Boolean Filter; /* filter dbx output (if Echo == false) ? */
  792. - void query_dbx_echo(command, echo, filter)
  793. - char *command;
  794. - int echo;
  795. - int filter;
  796. - {
  797. -     write_dbx(command);
  798. -     insert_command(command);
  799. -     Echo = echo;
  800. -     Filter = filter;
  801. -     Prompt = False;
  802. -     while (!Prompt)
  803. -         read_dbx();
  804. -     Parse = True;    /* Always reset Parse and Echo to True */
  805. -     Echo = True;
  806. - }
  807.   /*  core-file  
  808.    *  gdb does not display current line, file, func ..., so we send
  809. --- 578,581 ----
  810. ***************
  811. *** 588,594 ****
  812.       signal = Token.stop;                    /* signal number received */
  813.       
  814. !     query_dbx("frame 0\n"); /* this will update updown.line, updown.func and
  815. !                                 updown.file. (see updown_handler) */
  816.       
  817.       line = updown.line;
  818.       updown.line = 0;
  819. --- 591,608 ----
  820.       signal = Token.stop;                    /* signal number received */
  821.       
  822. !     /* because silly gdb 4.0 displays nothing with frame command when
  823. !     confirm is on (possibly a gdb bug) , I just reset confirm to on
  824. !     just for this command !. */
  825. !     if (new_gdb4()) 
  826. !         query_gdb("set confirm on\n",    PARSE_OFF | ECHO_OFF | FILTER_OFF);
  827. !     /* this will update updown.line, updown.func and updown.file.
  828. !     (see updown_handler) */
  829. !     query_gdb("frame 0\n", PARSE_ON | ECHO_OFF | FILTER_OFF);
  830.       
  831. +     if (new_gdb4()) /* reset confirm to off */
  832. +         query_gdb("set confirm off\n",    PARSE_OFF | ECHO_OFF | FILTER_OFF);
  833.       line = updown.line;
  834.       updown.line = 0;
  835. ***************
  836. *** 612,613 ****
  837. --- 626,709 ----
  838.       AdjustText(line); 
  839.   }
  840. + /*--------------------------------------------------------------------------+
  841. + |                                                                            |
  842. + |    Function to get the current source path directories.                    |
  843. + |                                                                            |
  844. + |     WARNING : this function is called at startup of xxgdb                    |
  845. + |     to test for gdb 4.0 or earlier versions.                                |
  846. + |     The 1st time that query_gdb_directories() is called,                    |
  847. + |     new_gdb is true, and 'show directories' command is                        |
  848. + |     issued to gdb. Then parse() in gdb_parser.c will test for                |
  849. + |     'show Unknown command' answer from gdb, and in that case                |
  850. + |     will set new_gdb to false. See show_is_undefined() below.                |
  851. + |                                                                            |
  852. + +--------------------------------------------------------------------------*/
  853. + void query_gdb_directories()
  854. + {
  855. +     if (new_gdb4()) /* (PW)28AUG91: test for gdb 4.0 */
  856. +         query_gdb("show directories\n", PARSE_ON | ECHO_OFF | FILTER_OFF);
  857. +     else
  858. +         query_gdb("info directories\n", PARSE_ON | ECHO_OFF | FILTER_OFF);
  859. + }
  860. + /*--------------------------------------------------------------------------+
  861. + |                                                                            |
  862. + |    Function to know if we are running the NEW gdb                            |
  863. + |                                                                            |
  864. + |    return TRUE if we are running gdb 4.0 (or 3.9x or higher)                |
  865. + |                                                                            |
  866. + |    WARNING : it is important that the default is gdb 4.0.                    |
  867. + |              (see comments on query_gdb_directories() above).                |
  868. + |                                                                            |
  869. + +--------------------------------------------------------------------------*/
  870. + static int new_gdb = True; /* default : we are running gdb 4.0 */
  871. + int new_gdb4()
  872. + {
  873. +     return new_gdb;
  874. + }
  875. + /*--------------------------------------------------------------------------+
  876. + |                                                                            |
  877. + |    Function to say that 'show' command is undefined and thus                |
  878. + |    that we are running an old version of gdb.                                |
  879. + |                                                                            |
  880. + +--------------------------------------------------------------------------*/
  881. + void show_is_undefined()
  882. + {
  883. +     new_gdb = False;
  884. + }
  885. + /*--------------------------------------------------------------------------+
  886. + |                                                                            |
  887. + |    Update compilation directory                                            |
  888. + |                                                                            |
  889. + |    This function is used for gdb 4.0 which uses the compilation            |
  890. + |    directory in the source path.                                            |
  891. + |                                                                            |
  892. + |    input : current compilation directory                                    |
  893. + |        (returned from 'info source' gdb command).                            |
  894. + |                                                                            |
  895. + |    output : none.                                                            |
  896. + |                                                                            |
  897. + +--------------------------------------------------------------------------*/
  898. + char cdir[MAXPATHLEN];       /* The compilation directory */
  899. + void info_source_handler(compile_dir)
  900. + char * compile_dir;
  901. + {
  902. +     if (compile_dir == NULL) {
  903. +         cdir[0] = 0;
  904. +         return;
  905. +     }
  906. +     if (strlen (compile_dir) < MAXPATHLEN)         /* check length */
  907. +         strcpy(cdir,compile_dir);
  908. +         
  909. +     if (LASTCH(cdir) == '/')                      /* remove last '/' */
  910. +         LASTCH(cdir) = '\0';
  911. + }
  912. diff -rc2 v1.04/gdb_parser.c v1.05/gdb_parser.c
  913. *** v1.04/gdb_parser.c    Wed May 22 16:46:47 1991
  914. --- v1.05/gdb_parser.c    Mon Sep 23 15:06:55 1991
  915. ***************
  916. *** 75,80 ****
  917. --- 75,134 ----
  918.   #include     <string.h>
  919.   
  920. + extern Boolean    Prompt;            /* True when gdb prompt arrives */
  921.   /*--------------------------------------------------------------------------+
  922.   |                                                                            |
  923. + |    Function to output a message and ring bell when a answer                |
  924. + |    from gdb has not been recognized (possibly because of bug                |
  925. + |    in xxgdb which does not anticipate this particular answer).                |
  926. + |                                                                            |
  927. + |    ECHO_ON means that all the output from gdb was displayed                |
  928. + |    on the dialog window (so no need to display any error message).            |
  929. + |    In particular we can arrive here because the user typed a                |
  930. + |    wrong command.                                                            |
  931. + |                                                                            |
  932. + |    ECHO_OFF means that the gdb command was issued internally by            |
  933. + |    xxgdb, and that the user has no knowledge of it.                        |
  934. + |                                                                            |
  935. + |    ECHO_ON and FILTER_ON means that only part of the                        |
  936. + |    gdb answer to the command is displayed in the dialog window.            |
  937. + |    What is displayed or not is chosen by the filter() function.            |
  938. + |    In fact, filter() in this case will display gdb error messages            |
  939. + |    from the command sent internally by xxgdb.                                |
  940. + |                                                                            |
  941. + |    This function will only display error messages when echo and            |
  942. + |    filter are off. This is more for xxgdb debug than for the user.            |
  943. + |                                                                            |
  944. + +--------------------------------------------------------------------------*/    
  945. + void unknown_output (outputstr, command, flags)
  946. + char *outputstr;
  947. + char *command;
  948. + int flags;
  949. + {
  950. +     if (command)
  951. +         {
  952. +         if (debug)
  953. +             fprintf(stderr, "\noutput from \"%s\" is not recognized\n", command);
  954. +     
  955. +         /* if the command was completely silent, we output this
  956. +         error message */
  957. +         
  958. +         if ((flags & (ECHO_ON | FILTER_ON)) == 0)
  959. +             {
  960. +             AppendDialogText("xxgdb error: output from \"");
  961. +             AppendDialogText(command);
  962. +             AppendDialogText("\" command is not recognized.\n");
  963. +             }
  964. +         }
  965. +         
  966. +     if (outputstr)
  967. +         if ((flags & (ECHO_ON | FILTER_ON)) == 0)
  968. +             AppendDialogText(outputstr);
  969. +     bell(0);    /* ring the bell in ALL cases */
  970. + }
  971. + /*--------------------------------------------------------------------------+
  972. + |                                                                            |
  973.   |    Function to remove all 'Reading in symbols' message                        |
  974.   |    from a string.                                                            |
  975. ***************
  976. *** 119,125 ****
  977.   | *                                                                            |
  978.   +--------------------------------------------------------------------------*/
  979. ! void parse(output, command)
  980.   char *output;
  981.   char *command;
  982.   {
  983.       int  command_type;
  984. --- 173,180 ----
  985.   | *                                                                            |
  986.   +--------------------------------------------------------------------------*/
  987. ! void parse(output, command, flags)
  988.   char *output;
  989.   char *command;
  990. + int flags;
  991.   {
  992.       int  command_type;
  993. ***************
  994. *** 129,133 ****
  995.       char *temp;
  996.       if(!command)temp="";else temp=command;
  997. !     fprintf(stderr, "parse(output = %s, command = %s)\n", output, temp);
  998.       }
  999.   
  1000. --- 184,188 ----
  1001.       char *temp;
  1002.       if(!command)temp="";else temp=command;
  1003. !     fprintf(stderr, "parse(output = %s, command = %s, flags = %d)\n", output, temp, flags);
  1004.       }
  1005.   
  1006. ***************
  1007. *** 136,147 ****
  1008.       if (output) strcpy(output, "");
  1009.   
  1010.       if (!command) {
  1011. !     if (match(output_pattern, output_string, O_DEBUG) != -1)
  1012.           {
  1013. !         debug_handler();
  1014.           if (match(output_pattern, output_string, O_CORE_FILE) != -1)
  1015.               core_file_handler();
  1016.           }
  1017. !     debug_init();
  1018.       XtFree(output_string);
  1019.       return;
  1020. --- 191,213 ----
  1021.       if (output) strcpy(output, "");
  1022.   
  1023. +     /* test for GDB start-up */
  1024.       if (!command) {
  1025. ! /* (PW)28AUG91 : do no test for O_DEBUG pattern because of gdb 4.0
  1026. ! who most of the times displays nothing before the promt.
  1027. ! if (match(output_pattern, output_string, O_DEBUG) != -1)
  1028. ! */
  1029.           {
  1030. !            query_gdb_directories();    /* will tell if running gdb 4.0 */
  1031. !            
  1032. !         debug_handler();    /* some init to gdb, and try to display main() */
  1033. !         
  1034. !         /* test if a core file was used in input arguments,
  1035. !         an display bomb if necessary. */
  1036. !         
  1037.           if (match(output_pattern, output_string, O_CORE_FILE) != -1)
  1038.               core_file_handler();
  1039.           }
  1040. !     debug_init();            /* read .gdbinit file (if any) */
  1041.       XtFree(output_string);
  1042.       return;
  1043. ***************
  1044. *** 148,160 ****
  1045.       }
  1046.       
  1047. !     if (!Parse)
  1048. !         {
  1049. !         XtFree(output_string);
  1050. !         return;
  1051. !         }
  1052.       if (match(output_pattern, output_string, O_BELL) != -1)
  1053.           {
  1054. !         bell(0);
  1055.           XtFree(output_string);
  1056.           return;
  1057. --- 214,229 ----
  1058.       }
  1059.       
  1060. !     /* if not GDB start-up */
  1061. !     
  1062.       if (match(output_pattern, output_string, O_BELL) != -1)
  1063.           {
  1064. !         /* test if this is 'show undefined'. If yes then we are
  1065. !         not executing the new gdb (4.0).
  1066. !             (see show_is_undefined in gdb_handler.c)
  1067. !         */
  1068. !         if (match(output_pattern, output_string, O_UNDEF_SHOW) != -1)
  1069. !             show_is_undefined();
  1070. !         else
  1071. !             unknown_output (output_string,command, flags);
  1072.           XtFree(output_string);
  1073.           return;
  1074. ***************
  1075. *** 194,198 ****
  1076.                   done_handler(message,signal);
  1077.               else
  1078. !                 bell(0);
  1079.               }
  1080.               
  1081. --- 263,267 ----
  1082.                   done_handler(message,signal);
  1083.               else
  1084. !                 unknown_output(output_string, command, flags);
  1085.               }
  1086.               
  1087. ***************
  1088. *** 209,213 ****
  1089.           updown_handler();
  1090.           else
  1091. !         bell(0);
  1092.           break;
  1093.       case C_SEARCH:
  1094. --- 278,282 ----
  1095.           updown_handler();
  1096.           else
  1097. !             unknown_output (output_string, command, flags);
  1098.           break;
  1099.       case C_SEARCH:
  1100. ***************
  1101. *** 215,219 ****
  1102.           search_handler();
  1103.           else
  1104. !         bell(0);
  1105.           break;
  1106.       case C_DELETE:
  1107. --- 284,288 ----
  1108.           search_handler();
  1109.           else
  1110. !             unknown_output(output_string, command, flags);
  1111.           break;
  1112.       case C_DELETE:
  1113. ***************
  1114. *** 224,228 ****
  1115.               list_handler();
  1116.           else
  1117. !         bell(0);
  1118.           break;
  1119.           
  1120. --- 293,297 ----
  1121.               list_handler();
  1122.           else
  1123. !             unknown_output(output_string, command, flags);
  1124.           break;
  1125.           
  1126. ***************
  1127. *** 231,235 ****
  1128.               break_handler();
  1129.           else
  1130. !         bell(0);
  1131.           break;
  1132.           
  1133. --- 300,304 ----
  1134.               break_handler();
  1135.           else
  1136. !             unknown_output(output_string, command, flags);
  1137.           break;
  1138.           
  1139. ***************
  1140. *** 238,242 ****
  1141.               info_dir_handler();
  1142.           else
  1143. !         bell(0);    
  1144.           break;
  1145.           
  1146. --- 307,311 ----
  1147.               info_dir_handler();
  1148.           else
  1149. !             unknown_output(output_string, command, flags);
  1150.           break;
  1151.           
  1152. ***************
  1153. *** 249,253 ****
  1154.               info_line_handler();        /* command was 'info line' */
  1155.           else
  1156. !         bell(0);
  1157.           break;
  1158.           
  1159. --- 318,322 ----
  1160.               info_line_handler();        /* command was 'info line' */
  1161.           else
  1162. !             unknown_output(output_string, command, flags);
  1163.           break;
  1164.           
  1165. ***************
  1166. *** 262,266 ****
  1167.               display_handler();
  1168.           else
  1169. !         bell(0);
  1170.           }
  1171.           break;
  1172. --- 331,335 ----
  1173.               display_handler();
  1174.           else
  1175. !             unknown_output(output_string, command, flags);
  1176.           }
  1177.           break;
  1178. ***************
  1179. *** 270,274 ****
  1180.               display_handler();
  1181.           else
  1182. !         bell(0);
  1183.           break;
  1184.   
  1185. --- 339,343 ----
  1186.               display_handler();
  1187.           else
  1188. !             unknown_output(output_string, command, flags);
  1189.           break;
  1190.   
  1191. ***************
  1192. *** 279,283 ****
  1193.               display_info_handler();
  1194.           else
  1195. !         bell(0);
  1196.           }
  1197.           break;
  1198. --- 348,352 ----
  1199.               display_info_handler();
  1200.           else
  1201. !             unknown_output(output_string, command, flags);
  1202.           }
  1203.           break;
  1204. ***************
  1205. *** 287,291 ****
  1206.               cd_handler(Token.mesg); 
  1207.           else
  1208. !         bell(0);
  1209.           break;
  1210.           
  1211. --- 356,360 ----
  1212.               cd_handler(Token.mesg); 
  1213.           else
  1214. !             unknown_output(output_string, command, flags);
  1215.           break;
  1216.           
  1217. ***************
  1218. *** 294,298 ****
  1219.               pwd_handler(Token.mesg);
  1220.           else
  1221. !         bell(0);
  1222.           break;
  1223.   
  1224. --- 363,367 ----
  1225.               pwd_handler(Token.mesg);
  1226.           else
  1227. !             unknown_output(output_string, command, flags);
  1228.           break;
  1229.   
  1230. ***************
  1231. *** 299,305 ****
  1232.       case C_FRAME_CURR:
  1233.           if (match(output_pattern, output_string, O_FRAME_CURR) != -1)
  1234. !         frame_curr_handler();
  1235.           else
  1236. !         bell(0);
  1237.           break;
  1238.   
  1239. --- 368,374 ----
  1240.       case C_FRAME_CURR:
  1241.           if (match(output_pattern, output_string, O_FRAME_CURR) != -1)
  1242. !             frame_curr_handler();
  1243.           else
  1244. !             unknown_output(output_string, command, flags);
  1245.           break;
  1246.   
  1247. ***************
  1248. *** 324,328 ****
  1249.               }
  1250.           else
  1251. !         bell(0);
  1252.           
  1253.           /* if PopupMode was true but GDB found an error in print
  1254. --- 393,397 ----
  1255.               }
  1256.           else
  1257. !             unknown_output(output_string, command, flags);
  1258.           
  1259.           /* if PopupMode was true but GDB found an error in print
  1260. ***************
  1261. *** 335,338 ****
  1262. --- 404,408 ----
  1263.           
  1264.       case C_SYMBOL_FILE:
  1265. +     case C_FILE:
  1266.           debug_handler(); 
  1267.           break;
  1268. ***************
  1269. *** 346,354 ****
  1270.       case C_CORE_FILE:
  1271.           if (match(output_pattern, output_string, O_CORE_FILE) != -1)
  1272. !         core_file_handler();
  1273.           else
  1274. !         bell(0);
  1275.           break;
  1276.           
  1277.       default:
  1278.           break;
  1279. --- 416,434 ----
  1280.       case C_CORE_FILE:
  1281.           if (match(output_pattern, output_string, O_CORE_FILE) != -1)
  1282. !             core_file_handler();
  1283.           else
  1284. !             unknown_output(output_string, command, flags);
  1285.           break;
  1286.           
  1287. +     /* in case of 'info source', we do not call unknown_output()
  1288. +     if the pattern is not matched, because we only test for the
  1289. +     'compilation directory' line. When there is no compilation
  1290. +     directory, there is no match and there is no error... */
  1291. +     
  1292. +     case C_INFO_SOURCE:
  1293. +         if (match(output_pattern, output_string, O_INFO_SOURCE) != -1)
  1294. +             info_source_handler(Token.mesg); 
  1295. +         break;
  1296.       default:
  1297.           break;
  1298. ***************
  1299. *** 662,666 ****
  1300.               AppendDialogText(command);
  1301.           source_handler();    
  1302. -         send_command(" \n");    /* ask GDB to redisplay its prompt */
  1303.           return TRUE;
  1304.           }
  1305. --- 742,745 ----
  1306. ***************
  1307. *** 681,684 ****
  1308. --- 760,765 ----
  1309.   |                                                                            |
  1310.   +--------------------------------------------------------------------------*/
  1311. + static int command_sent = 0;    /* flag gdb is busy : send no more command to gdb. */
  1312.   int gdb_define_command(command,fp)
  1313.   char *command;
  1314. ***************
  1315. *** 693,698 ****
  1316.           {
  1317.           AppendDialogText(command);
  1318. -         send_command(command);
  1319.           
  1320.   /*
  1321.                   gdb could ask :
  1322. --- 774,787 ----
  1323.           {
  1324.           AppendDialogText(command);
  1325.           
  1326. +         /* because silly gdb 4.0 displays nothing with def/doc command when
  1327. +         confirm is on (possibly a gdb bug) , I just reset confirm to on
  1328. +         just for this command !. */
  1329. +         
  1330. +         if (new_gdb4()) 
  1331. +             query_gdb("set confirm on\n",    PARSE_OFF | ECHO_OFF | FILTER_OFF);
  1332. +         write_dbx (command);
  1333. +         
  1334.   /*
  1335.                   gdb could ask :
  1336. ***************
  1337. *** 768,771 ****
  1338. --- 857,867 ----
  1339.               }
  1340.           
  1341. +         command_sent++;                /* flag gdb is busy (because of read_gdb) */
  1342. +         insert_command("end\n");    /* insert 'end' at head of queue */
  1343. +         read_until_prompt (PARSE_OFF | ECHO_ON | FILTER_OFF);    /* return when prompt */
  1344. +         if (new_gdb4()) /* reset confirm to off */
  1345. +             query_gdb("set confirm off\n",    PARSE_OFF | ECHO_OFF | FILTER_OFF);
  1346.           return TRUE;
  1347.           }
  1348. ***************
  1349. *** 774,775 ****
  1350. --- 870,1073 ----
  1351.   }
  1352.   
  1353. + /*--------------------------------------------------------------------------+
  1354. + |                                                                            |
  1355. + |    Read gdb output until fgets returns no string.                            |
  1356. + |                                                                            |
  1357. + |    The ouptut is process according to flags.                                |
  1358. + |                                                                            |
  1359. + |    In case the gdb prompt is found, the command on top of the                |
  1360. + |    command queue (ie, the one which is assumed to correspond                |
  1361. + |    to this output) is remove from the queue, and 'command_sent'            |
  1362. + |    is decremented to say that gdb is no longer busy.                        |
  1363. + |                                                                            |
  1364. + +--------------------------------------------------------------------------*/
  1365. + static int parse_flags = PARSE_ON | ECHO_ON | FILTER_ON; /* last flags used in read_gdb */
  1366. + void read_gdb (flags)
  1367. + int flags;
  1368. + {
  1369. +     static char *output = NULL;     /* buffer for gdb output */
  1370. +     static char *next_string = NULL;
  1371. +     static char *command;
  1372. +     char     *string = NULL;
  1373. +     char     s[LINESIZ];
  1374. +     Boolean     more;
  1375. +     
  1376. +     parse_flags = flags;     /* just remember flags for read_dbx() */
  1377. +     
  1378. +     more = True;
  1379. +     while (more) {
  1380. +     Prompt = False;
  1381. +     /* keep reading until no more or until prompt arrives */
  1382. +     while (more = fgets(s, LINESIZ, dbxfp) && !Prompt)
  1383. +         {
  1384. +         if (debug)
  1385. +             fprintf(stderr, "=>%s", s);
  1386. +             
  1387. +         /* receive prompt? */
  1388. +         if (strncmp(s, dbxprompt, strlen(dbxprompt)) == NULL)
  1389. +             {
  1390. +             Prompt = True;
  1391. +             
  1392. +             /* more stuff behind prompt? */
  1393. +             if (s[strlen(dbxprompt)])
  1394. +                 /* remember it */
  1395. +                 next_string = XtNewString(s+strlen(dbxprompt));
  1396. +                 
  1397. +             /* destroy contents */
  1398. +             strcpy(s, "");
  1399. +             }
  1400. +             
  1401. +         string = concat(string, s);
  1402. +         strcpy(s, "");
  1403. +         }
  1404. +         
  1405. +     output = concat(output, string);
  1406. +     
  1407. +     command = get_command();            /* read queue's top command  */
  1408. +         
  1409. +     if (flags & FILTER_ON)
  1410. +         filter(string, output, command);
  1411. +         
  1412. +     if ((flags & ECHO_ON) && Prompt)
  1413. +         AppendDialogText(xdbxprompt);
  1414. +         
  1415. +     if (string) {
  1416. +         XtFree(string);
  1417. +         string = NULL;
  1418. +     }
  1419. +     
  1420. +     if (next_string) {
  1421. +         string = concat(string, next_string);
  1422. +         XtFree(next_string);
  1423. +         next_string = NULL;
  1424. +     }
  1425. +     
  1426. +     if ((flags & PARSE_ON) && Prompt) {
  1427. +         parse (output, command, flags);
  1428. +     }
  1429. +     
  1430. +     /* note : it is important to decrement 'command_sent' AFTER
  1431. +     parse() is executed, so that no other commands will mix-up
  1432. +     the commands sent by the function handlers executed by parse().
  1433. +     */
  1434. +     
  1435. +     if (Prompt) {
  1436. +         delete_command();        /* remove top command from queue */
  1437. +         if (command && command_sent)
  1438. +             command_sent--;
  1439. +         XtFree(output);
  1440. +         output = NULL;
  1441. +     }
  1442. +     }
  1443. + }
  1444. + /*--------------------------------------------------------------------------+
  1445. + | *                                                                            |
  1446. + | *     This is a callback procedure invoked everytime when input is pending    |
  1447. + | *     on the file descriptor to dbx.                                            |
  1448. + | *     o reads all the data available on the file descriptor line by line        |
  1449. + | *       into local variable 'string' and global variable 'output'.            |
  1450. + | *       'output' records the entire dbx output whereas 'string' records        |
  1451. + | *       only the data read in this invocation of read_dbx().                    |
  1452. + | *     o in Echo mode, the contents in 'string' is edited by filter()            |
  1453. + | *       before it gets displayed on the dialog window.                        |
  1454. + | *     o once the dbx prompt is read, calls parse() to analyse the dbx output |
  1455. + | *       and take appropriate action.                                            |
  1456. + | *                                                                            |
  1457. + +--------------------------------------------------------------------------*/
  1458. + /* ARGSUSED */
  1459. + void read_dbx(master, source, id)
  1460. + XtPointer master;
  1461. + int       *source;
  1462. + XtInputId *id;
  1463. + {
  1464. +     read_gdb (parse_flags);
  1465. +     
  1466. +     write_dbx_available ();
  1467. + }
  1468. + /*--------------------------------------------------------------------------+
  1469. + |                                                                            |
  1470. + |    Read gdb output until prompt.                                            |
  1471. + |    The ouptut is process according to flags.                                |
  1472. + |                                                                            |
  1473. + +--------------------------------------------------------------------------*/
  1474. + void read_until_prompt (flags)
  1475. + int flags;
  1476. + {
  1477. +     Prompt = False;
  1478. +     while (!Prompt)
  1479. +         read_gdb (flags);
  1480. + }
  1481. + /*--------------------------------------------------------------------------+
  1482. + |                                                                            |
  1483. + | *     Sends a command to gdb and read the corresponding output, directly        |
  1484. + | *     invoking the Xt input procedure, read_gdb().                            |
  1485. + | *                                                                            |
  1486. + | * Same as query_dbx() in dbx.c except that echo, filter and parse.        |
  1487. + | *     are passed in argument flags:                                            |
  1488. + | * PARSE_ON | PARSE_OFF | ECHO_ON | ECHO_OFF | FILTER_ON | FILTER_OFF        |
  1489. + | *                                                                            |
  1490. + +--------------------------------------------------------------------------*/
  1491. + void query_gdb(command, flags)
  1492. + char *command;
  1493. + int flags;
  1494. + {
  1495. +     command_sent++;                /* flag gdb is busy */
  1496. +     
  1497. +     write_dbx(command);            /* send command to gdb */
  1498. +     
  1499. +     insert_command(command);    /* insert at head of queue */
  1500. +     read_until_prompt (flags);    /* return when prompt */
  1501. +     
  1502. +     /* test if we are at the top command, and if some commands are waiting */
  1503. +     
  1504. +     write_dbx_available ();    /* send next waiting command */
  1505. + }
  1506. + /*--------------------------------------------------------------------------+
  1507. + |                                                                            |
  1508. + |    Function to send the first command of the command queue to gdb only in    |
  1509. + |    case gdb is waiting for a command.                                        |
  1510. + |                                                                            |
  1511. + |    WARNING : we must test for 'source' command.                            |
  1512. + |                                                                            |
  1513. + |    The commands in the command queue are from the keyboard and from        |
  1514. + |    the buttons.                                                            |
  1515. + |                                                                            |
  1516. + +--------------------------------------------------------------------------*/
  1517. + void write_dbx_available()
  1518. + {
  1519. + char *command;
  1520. +     if (command = get_command())
  1521. +         {
  1522. +         if (command_sent++ == 0)    
  1523. +             {
  1524. +             /* here, the source command is already displayed, say echo command = FALSE */
  1525. +             
  1526. +             if (gdb_source_command(command,FALSE))
  1527. +                 {
  1528. +                 delete_command();        /* remove source command from top of queue */
  1529. +                 command_sent--;
  1530. +                 /* tell gdb to send its prompt */
  1531. +                 query_gdb(" \n", PARSE_OFF | ECHO_OFF | FILTER_OFF);
  1532. +                 return;
  1533. +                 }
  1534. +                 
  1535. +             parse_flags = PARSE_ON | ECHO_ON | FILTER_ON; /* for read_gdb */
  1536. +             write_dbx (command);
  1537. +             Prompt = False;
  1538. +             return;                    /* return with command_sent incremented */
  1539. +             }
  1540. +         else
  1541. +             {
  1542. +             if (command_sent)    /* should never be zero ! (just to be safe) */
  1543. +                 command_sent--;    /* command is not sent, restore previous value */
  1544. +             return;
  1545. +             }
  1546. +         }
  1547. + }
  1548. diff -rc2 v1.04/gdb_regex.h v1.05/gdb_regex.h
  1549. *** v1.04/gdb_regex.h    Thu May 30 16:54:06 1991
  1550. --- v1.05/gdb_regex.h    Mon Sep 23 15:07:04 1991
  1551. ***************
  1552. *** 103,106 ****
  1553. --- 103,108 ----
  1554.   #define O_READING_SYMBOLS    19            /* special for filter_reading_symbols */
  1555.   #define O_CORE_FILE            20
  1556. + #define O_UNDEF_SHOW        21            /* test for undefined show command (for gdb 4.0) */
  1557. + #define O_INFO_SOURCE        22            /* to get compilation directory (for gdb 4.0) */
  1558.   
  1559.   
  1560. ***************
  1561. *** 131,134 ****
  1562. --- 133,138 ----
  1563.   #define C_DOCUMENT        23
  1564.   #define C_END            24
  1565. + #define C_INFO_SOURCE    25            /* new for gdb 4.0 to get compilation directory */
  1566. + #define C_FILE            26            /* new for gdb 4.0 : file command */
  1567.   
  1568.   /*--------------------------------------------------------------------------+
  1569. ***************
  1570. *** 432,435 ****
  1571. --- 436,449 ----
  1572.        {  2, 3, -1, -1, -1, -1}
  1573.       },
  1574. +     /* Undefined show command (for test gdb 4.0) */
  1575. +     {"\\(Undefined command: \"show\".\n\\)",
  1576. +      NULL,
  1577. +      {-1, -1, -1, -1, -1}
  1578. +     },
  1579. +     /* info source (for gdb 4.0) */
  1580. +     {"\\(.*\n\\)*Compilation directory is \\([^ ]+\\)\n\\(.*\n\\)*",
  1581. +      NULL,
  1582. +      { 2, -1, -1, -1, -1, -1}
  1583. +     },
  1584.       NULL 
  1585.   };
  1586. ***************
  1587. *** 450,455 ****
  1588.       jump - until - u */
  1589.       /* CRL mod 22 4/5/91 GWC - added attach to this list for gdbvx */
  1590.       
  1591. !     {"[ ]*\\(run\\|r\\|cont\\|c\\|next\\|n\\|step\\|s\\|nexti\\|stepi\\|ni\\|si\\|ret[urn]*\\|j[ump]*\\|unt[il]*\\|u\\|at[tach]*\\)\\( .*\\)?\n",
  1592.                                               NULL, {-1, -1, -1, -1, -1, -1}},
  1593.       /* break - tbreak */
  1594. --- 464,470 ----
  1595.       jump - until - u */
  1596.       /* CRL mod 22 4/5/91 GWC - added attach to this list for gdbvx */
  1597. +     /* (PW) - added target to this list for gdb 4.0 */
  1598.       
  1599. !     {"[ ]*\\(run\\|r\\|cont\\|c\\|next\\|n\\|step\\|s\\|nexti\\|stepi\\|ni\\|si\\|ret[urn]*\\|j[ump]*\\|unt[il]*\\|u\\|at[tach]*\\|ta[rget]*\\)\\( .*\\)?\n",
  1600.                                               NULL, {-1, -1, -1, -1, -1, -1}},
  1601.       /* break - tbreak */
  1602. ***************
  1603. *** 456,460 ****
  1604.       {"[ ]*\\(t\\)?\\(b\\|br\\|bre\\|brea\\|break\\)\\( .*\\)?\n",
  1605.                                               NULL, {-1, -1, -1, -1, -1, -1}},
  1606. !     {"[ ]*info[ ]+directories[ ]*\n",        NULL, {-1, -1, -1, -1, -1, -1}},
  1607.       
  1608.       /* 'frame' is special case of 'frame n' since it does not change the
  1609. --- 471,476 ----
  1610.       {"[ ]*\\(t\\)?\\(b\\|br\\|bre\\|brea\\|break\\)\\( .*\\)?\n",
  1611.                                               NULL, {-1, -1, -1, -1, -1, -1}},
  1612. !     /* (PW)28AUG91 : add show for gdb 4.0 */
  1613. !     {"[ ]*\\(info\\|show\\)[ ]+directories[ ]*\n",        NULL, {-1, -1, -1, -1, -1, -1}},
  1614.       
  1615.       /* 'frame' is special case of 'frame n' since it does not change the
  1616. ***************
  1617. *** 472,476 ****
  1618.                                               NULL, {-1, -1, -1, -1, -1, -1}},
  1619.                                               
  1620. !     {"[ ]*fi[nish]*[ ]*\n",                    NULL, {-1, -1, -1, -1, -1, -1}},
  1621.       {"[ ]*info[ ]+line[ ]*\n",                NULL, {-1, -1, -1, -1, -1, -1}},
  1622.       
  1623. --- 488,493 ----
  1624.                                               NULL, {-1, -1, -1, -1, -1, -1}},
  1625.                                               
  1626. !     /* because of gdb 4.0 use fin[ish] instead of fi[nish] */                
  1627. !     {"[ ]*fin[ish]*[ ]*\n",                    NULL, {-1, -1, -1, -1, -1, -1}},
  1628.       {"[ ]*info[ ]+line[ ]*\n",                NULL, {-1, -1, -1, -1, -1, -1}},
  1629.       
  1630. ***************
  1631. *** 508,512 ****
  1632.       
  1633.       /* exec-file (just used internally) */
  1634. !     {"[ ]*exec-file .*\n",                     NULL, {-1, -1, -1, -1, -1, -1}},
  1635.   
  1636.       /* core-file */
  1637. --- 525,529 ----
  1638.       
  1639.       /* exec-file (just used internally) */
  1640. !     {"[ ]*ex[ec-file]*.*\n",                 NULL, {-1, -1, -1, -1, -1, -1}},
  1641.   
  1642.       /* core-file */
  1643. ***************
  1644. *** 519,523 ****
  1645. --- 536,545 ----
  1646.       /* end of define or document */
  1647.       {"[ ]*end[ ]*.*",                         NULL, {-1, -1, -1, -1, -1, -1}},
  1648. +     
  1649. +     /* info source */
  1650. +     {"[ ]*info[ ]+source[ ]*\n",            NULL, {-1, -1, -1, -1, -1, -1}},
  1651.   
  1652. +     /* file */
  1653. +     {"[ ]*file .*\n",                         NULL, {-1, -1, -1, -1, -1, -1}},
  1654.       NULL
  1655.   };
  1656. diff -rc2 v1.04/global.h v1.05/global.h
  1657. *** v1.04/global.h    Tue May  7 14:59:20 1991
  1658. --- v1.05/global.h    Mon Sep 23 16:04:23 1991
  1659. ***************
  1660. *** 207,213 ****
  1661.   extern PatternRec       dataPattern[];     /* data display pattern */
  1662.   
  1663.   extern Boolean     Echo;            /* echo dbx output onto window ? */
  1664. - extern Boolean    Prompt;            /* command or program input ? */
  1665.   extern Boolean    Parse;            /* flag for parser */
  1666.   extern Boolean    FalseSignal;        /* real/false signal ? */
  1667.   extern Boolean    PopupMode;        /* True if graphical display */
  1668. --- 207,216 ----
  1669.   extern PatternRec       dataPattern[];     /* data display pattern */
  1670.   
  1671. + #ifndef GDB
  1672.   extern Boolean     Echo;            /* echo dbx output onto window ? */
  1673.   extern Boolean    Parse;            /* flag for parser */
  1674. + #endif    /* not GDB */
  1675. + extern Boolean    Prompt;            /* command or program input ? */
  1676.   extern Boolean    FalseSignal;        /* real/false signal ? */
  1677.   extern Boolean    PopupMode;        /* True if graphical display */
  1678. ***************
  1679. *** 225,229 ****
  1680.   
  1681.   #ifdef GDB
  1682. - extern Boolean     Filter;            /* filter dbx output (if Echo == false) ? */
  1683.   extern void         display_info_handler();
  1684.   extern void         break_handler();
  1685. --- 228,231 ----
  1686. ***************
  1687. *** 232,234 ****
  1688. --- 234,245 ----
  1689.   extern void         info_line_handler();
  1690.   extern void         info_break_handler();
  1691. + extern void         info_source_handler();
  1692. + extern void         query_gdb();
  1693. + extern void         read_until_prompt();
  1694. + extern void         read_gdb();
  1695. + extern void         unknown_output();
  1696. + extern void         write_dbx_available();
  1697. + extern void         query_gdb_directories();
  1698. + extern void         show_is_undefined();
  1699. + extern void         read_source_file();
  1700.   #endif
  1701. diff -rc2 v1.04/handler.c v1.05/handler.c
  1702. *** v1.04/handler.c    Wed Apr  3 14:13:41 1991
  1703. --- v1.05/handler.c    Fri Sep 20 16:04:35 1991
  1704. ***************
  1705. *** 89,94 ****
  1706. --- 89,96 ----
  1707.   #endif
  1708.   
  1709. + #ifndef GDB
  1710.   Boolean        Echo = True;        /* display dbx output if true */
  1711.   static Boolean    Skip_func_handler = False;
  1712. + #endif
  1713.   
  1714.   /*  Display text starting from the top position specified by pos */
  1715. diff -rc2 v1.04/parser.c v1.05/parser.c
  1716. *** v1.04/parser.c    Tue Jan 15 11:05:07 1991
  1717. --- v1.05/parser.c    Fri Sep 20 16:04:38 1991
  1718. ***************
  1719. *** 95,99 ****
  1720. --- 95,101 ----
  1721.   
  1722.   Tokens     Token;            /* gloabl token structure */
  1723. + #ifndef GDB
  1724.   Boolean    Parse = True;        /* Parse flag for parse routine */
  1725. + #endif
  1726.   
  1727.   /*
  1728. diff -rc2 v1.04/patchlevel.h v1.05/patchlevel.h
  1729. *** v1.04/patchlevel.h    Mon Jul 15 16:03:21 1991
  1730. --- v1.05/patchlevel.h    Wed Sep 11 16:53:48 1991
  1731. ***************
  1732. *** 1 ****
  1733. ! #define PATCHLEVEL 2
  1734. --- 1 ----
  1735. ! #define PATCHLEVEL 3
  1736. diff -rc2 v1.04/source.c v1.05/source.c
  1737. *** v1.04/source.c    Thu May 30 17:53:57 1991
  1738. --- v1.05/source.c    Fri Sep 20 16:04:31 1991
  1739. ***************
  1740. *** 619,624 ****
  1741.       for (i=0; dirList[i]; i++) {
  1742.       sprintf(command, "directory %s\n", dirList[i]);
  1743. !     Parse = False;
  1744. !     query_dbx(command);
  1745.       }
  1746.   #else /* not NeXT */
  1747. --- 619,623 ----
  1748.       for (i=0; dirList[i]; i++) {
  1749.       sprintf(command, "directory %s\n", dirList[i]);
  1750. !     query_gdb (command, PARSE_OFF | ECHO_OFF | FILTER_OFF);
  1751.       }
  1752.   #else /* not NeXT */
  1753. ***************
  1754. *** 630,641 ****
  1755.   #ifdef GDB
  1756.       sprintf(command, "directory %s\n", list);
  1757.   #else
  1758.       sprintf(command, "use %s\n", list);
  1759. - #endif /* GDB */
  1760.       Parse = False;
  1761.       query_dbx(command);
  1762.   #endif /* not NeXT */
  1763.   }
  1764.   
  1765.   
  1766.   /*  Returns the full pathname of a given file.
  1767. --- 629,644 ----
  1768.   #ifdef GDB
  1769.       sprintf(command, "directory %s\n", list);
  1770. +     query_gdb (command, PARSE_OFF | ECHO_OFF | FILTER_OFF);
  1771.   #else
  1772.       sprintf(command, "use %s\n", list);
  1773.       Parse = False;
  1774.       query_dbx(command);
  1775. + #endif /* GDB */
  1776.   #endif /* not NeXT */
  1777.   }
  1778.   
  1779. + #ifdef GDB    /* (PW)11SEP91 : for gdb 4.0 */
  1780. + extern char cdir[];    /* compilation directory */
  1781. + #endif
  1782.   
  1783.   /*  Returns the full pathname of a given file.
  1784. ***************
  1785. *** 659,662 ****
  1786. --- 662,673 ----
  1787.       else if (strcmp(dirList[i], ".") == NULL)
  1788.            sprintf(pathname, "%s/%s", cwd, filename);
  1789. +          
  1790. + #ifdef GDB    /* (PW)(SH)11SEP91 : for gdb 4.0 */
  1791. +     else if (strcmp(dirList[i], "$cwd") == NULL)
  1792. +          sprintf(pathname, "%s/%s", cwd, filename);
  1793. +     else if (strcmp(dirList[i], "$cdir") == NULL)
  1794. +          sprintf(pathname, "%s/%s", cdir, filename);
  1795. + #endif /* GDB */
  1796.       else if (*dirList[i] == '/' || *dirList[i] == '~')
  1797.            sprintf(pathname, "%s/%s", dirList[i], filename);
  1798. ***************
  1799. *** 730,734 ****
  1800.   {
  1801.   #ifdef GDB
  1802. !     query_dbx("info line\n");
  1803.   #else
  1804.       query_dbx("file\n");
  1805. --- 741,745 ----
  1806.   {
  1807.   #ifdef GDB
  1808. !     query_gdb ("info line\n", PARSE_ON | ECHO_OFF | FILTER_OFF);
  1809.   #else
  1810.       query_dbx("file\n");
  1811. diff -rc2 v1.04/xdbx.c v1.05/xdbx.c
  1812. *** v1.04/xdbx.c    Mon Jul 15 15:50:50 1991
  1813. --- v1.05/xdbx.c    Wed Sep 11 16:57:35 1991
  1814. ***************
  1815. *** 72,76 ****
  1816.   
  1817.   #ifdef GDB
  1818. ! #define XGDBVERSION    "1.04"
  1819.   #endif
  1820.   
  1821. --- 72,76 ----
  1822.   
  1823.   #ifdef GDB
  1824. ! #define XGDBVERSION    "1.05"
  1825.   #endif
  1826.   
  1827.  
  1828. --
  1829. Dan Heller
  1830. Z-Code Software    O'Reilly && Associates       Comp-sources-x:
  1831. President          Senior Writer                comp-sources-x@uunet.uu.net
  1832. argv@z-code.com    argv@ora.com                 [^^^  this address only!]
  1833.